﻿#region Usings

using System.Data.Entity.ModelConfiguration;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data.Configuration
{
    public class TravelerCombinationMap : EntityTypeConfiguration<TravelerCombination>
    {
        public TravelerCombinationMap()
        {
            ToTable("TravelerCombinations");
            HasKey(travelerCombination => travelerCombination.Id);

            Property(travelerCombination => travelerCombination.TravelerCount).IsRequired();

            HasRequired(travelerCombination => travelerCombination.Tariff).WithMany(tariff => tariff.TravelerCombinations);
            HasMany(travelerCombination => travelerCombination.Travelers).WithRequired(
                traveler => traveler.TravelerCombination).WillCascadeOnDelete(true);
        }
    }
}